package com.kfm.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter("/life")
public class LifeCycleFilter implements Filter {

    public LifeCycleFilter(){
        System.out.println("LifeCycleFilter.LifeCycleFilter");
    }
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("LifeCycleFilter.init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println(this.getClass().getName() + ".doFilter  start");

        // 放行
        filterChain.doFilter(servletRequest, servletResponse);

        System.out.println(this.getClass().getName() + ".doFilter  end");

    }

    @Override
    public void destroy() {
        System.out.println("LifeCycleFilter.destroy");
    }
}
